package com.newtouch.krd_app.util;

import android.content.Context;
import android.media.MediaPlayer;

/**
 * author : TQ
 * time   : 2023/2/16
 * desc   :mp3播放
 */

public class MusicServer {
    private static MediaPlayer mp = null;

    public static void play(Context context, int resource) {
        stop(context);
        mp = MediaPlayer.create(context, resource);
        mp.setLooping(true);
        mp.start();
    }

    public static void stop(Context context) {
        // TODO Auto-generated method stub
        if (mp != null) {
            mp.stop();
            mp.release();
            mp = null;
        }
    }
}
